package cn.devzyh.oms.wsms.api.feign;

import cn.devzyh.oms.common.core.constant.SecurityConstants;
import cn.devzyh.oms.common.core.constant.ServiceNameConstants;
import cn.devzyh.oms.common.core.util.R;
import cn.devzyh.oms.common.mybatis.domain.PageQuery;
import cn.devzyh.oms.wsms.api.dto.StockDTO;
import cn.devzyh.oms.wsms.api.entity.Stock;
import cn.devzyh.oms.wsms.api.vo.StockVO;
import cn.hutool.core.collection.CollectionUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 库存操作
 *
 * @author devzyh
 * @date 2023-10-31
 */
@FeignClient(contextId = "remoteStockService", value = ServiceNameConstants.WSMS_SERVICE)
public interface RemoteStockService {

	/**
	 * 库存调整
	 *
	 * @param dto  库存数据对象
	 * @param from 调用标志
	 * @return R
	 */
	@PostMapping("/stock/adjust")
	R<String> adjust(@RequestBody StockDTO dto, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 批量库存调整
	 *
	 * @param list     库存操作列表
	 * @param rollback 发生错误时是否回滚
	 * @param from     调用标志
	 * @return R
	 */
	@PostMapping("/stock/batch_adjust")
	R<String> batchAdjust(@RequestBody List<StockDTO> list, @RequestParam boolean rollback,
						  @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 库存在途
	 *
	 * @param dto  库存数据对象
	 * @param from 调用标志
	 * @return R
	 */
	@PostMapping("/stock/in_transit")
	R<Stock> inTransit(@RequestBody StockDTO dto, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 库存入库
	 *
	 * @param dto  库存数据对象
	 * @param from 调用标志
	 * @return R
	 */
	@PostMapping("/stock/inbound")
	R<Stock> inbound(@RequestBody StockDTO dto, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 库存分配
	 *
	 * @param dto  库存数据对象
	 * @param from 调用标志
	 * @return R
	 */
	@PostMapping("/stock/allocate")
	R<Stock> allocate(@RequestBody StockDTO dto, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 库存出库
	 *
	 * @param dto  库存数据对象
	 * @param from 调用标志
	 * @return R
	 */
	@PostMapping("/stock/outbound")
	R<Stock> outbound(@RequestBody StockDTO dto, @RequestHeader(SecurityConstants.FROM) String from);

}
